﻿using AgNet.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AgNet.Tests
{
    [TestClass]
    public class FetchSongList
    {
        private static AgNetClient client;
        private static AgSession session;

        [ClassInitialize]
        public static void InitializeClient(TestContext context)
        {
            client = new AgNetClient(TestVariables.ClientId, TestVariables.AppSecret);
            session = client.Login(TestVariables.Email, TestVariables.Password);
        }

        [TestMethod]
        public void CanFetchSongs()
        {
            var playLists = client.FetchResourceList(ResourceTypes.playlists, 0, ImageSizes.small, session);
            Assert.IsNotNull(playLists);

            foreach (var playList in playLists.Resources)
            {
                var songList = client.FetchSongList(ResourceTypes.playlist, playList.Id, 0, session);
                Assert.IsNotNull(songList);
                CheckResponseBase(songList);
            }
        }

        private static void CheckResponseBase(AgResponseBase response)
        {
            Assert.IsNotNull(response.Etag);
            Assert.IsFalse(response.HelperStatus == HelperStatuses.invalid);
            Assert.IsFalse(response.Type == ResourceTypes.invalid);
        }
    }
}
